package com.snail.starter.kafka;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
*
* @author: snail framework
* @Date: 2023/4/20 下午4:04
* @Version: 1.0.0
*/
@RestController
@RequestMapping("/kafka")
public class KafkaController {

    @Resource
    KafkaApplicationContext kafkaApplicationContext;

    @GetMapping("/unsubscribe")
    public void unsubscribe(){
        kafkaApplicationContext.unsubscribeAll();
    }

    @GetMapping("/{topic}/unsubscribe/{group}")
    public void unsubscribeOne(@PathVariable("topic") String topic, @PathVariable("group") String group){
        kafkaApplicationContext.unsubscribe(topic, group);
    }

    @GetMapping("/subscribe")
    public void subscribe() throws Exception {
        kafkaApplicationContext.subscribeAll();
    }

}